package Homework;

public class Homework01 {

    public static void main(String[] args) {
        // 创建String类型的对象并打印
        String s1 = new String("ABCD123!@#$%ab");
        int[] sum = new int[4];
        //使用 for循环及if elseif else循环对字符串字符进行阿斯克码值得比较
        for(int i = 0;i < s1.length();i++) {
            if('A' <= s1.charAt(i) && s1.charAt(i) <= 'Z') {
                sum[0]++;
            }else if('a' <= s1.charAt(i) && s1.charAt(i) <= 'z') {
                sum[1]++;
            }else if('0' <= s1.charAt(i) && s1.charAt(i) <= '9') {
                sum[2]++;
            }else {
                sum[3]++;
            }
        }
        // 打印结果
        System.out.println("字符串中出现的大写字母个数为：" + sum[0] + "个");
        System.out.println("字符串中出现的小写字母个数为：" + sum[1] + "个");
        System.out.println("字符串中出现的数字字符个数为：" + sum[2] + "个");
        System.out.println("字符串中出现的其他字符个数为：" + sum[3] + "个");
    }
}
